package com.mhc.suzuki.manager.impl;

import com.mhc.suzuki.dal.mapper.ext.AccidentExtMapper;
import com.mhc.suzuki.dal.model.AccidentDO;
import com.mhc.suzuki.dal.query.AccidentQuery;
import com.mhc.suzuki.manager.AccidentManager;
import com.subaru.common.query.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;


/**
 * Manager for Accident.
 */

@Component
public class AccidentManagerImpl implements AccidentManager {


    @Autowired
    protected AccidentExtMapper accidentExtMapper;

    /**
     * query count by query condition.
     */
    @Override
    public int countByQuery(AccidentQuery query) {
        return accidentExtMapper.countByQuery(query);
    }

    /**
     * delete by query condition.
     */
    @Override
    public int deleteByQuery(AccidentQuery query) {
        return accidentExtMapper.deleteByQuery(query);
    }

    /**
     * delete by primary key.
     */
    @Override
    public int deleteByPrimaryKey(AccidentDO record) {
        return accidentExtMapper.deleteByPrimaryKey(record);
    }

    /**
     * insert selective.
     */
    @Override
    public long insertSelective(AccidentDO record) {
        return accidentExtMapper.insertSelective(record);
    }

    /**
     * select by query condition.
     */
    @Override
    public List<AccidentDO> selectByQuery(AccidentQuery query) {
        return accidentExtMapper.selectByQuery(query);
    }

    /**
     * select by query condition with page.
     */
    @Override
    public PageResult<AccidentDO> selectByQueryWithPage(AccidentQuery query) {
        PageResult<AccidentDO> result = new PageResult<AccidentDO>();
        result.setPageSize(query.getPageSize());
        result.setPageNo(query.getPageNo());
        result.setTotalCount(this.countByQuery(query));
        result.setResult(this.selectByQuery(query));
        return result;
    }

    /**
     * select by primary key.
     */
    @Override
    public AccidentDO selectByPrimaryKey(Long id) {
        return accidentExtMapper.selectByPrimaryKey(id);
    }

    /**
     * update by query condition selective.
     */
    @Override
    public int updateByQuerySelective(AccidentDO record, AccidentQuery query) {
        return accidentExtMapper.updateByQuerySelective(record, query);
    }

    /**
     * update by query condition.
     */
    @Override
    public int updateByQuery(AccidentDO record, AccidentQuery query) {

        return accidentExtMapper.updateByQuery(record, query);
    }

    /**
     * update by primary key selective.
     */
    @Override
    public int updateByPrimaryKeySelective(AccidentDO record) {
        return accidentExtMapper.updateByPrimaryKeySelective(record);
    }
}